﻿using Core.Extension;
using Core.Mgr;
using Logic.Global;
using UnityEngine;
using Environment = Logic.Global.Environment;

namespace Core.Mgrs
{
    public class GUITestMgr : SingletonMono<GUITestMgr>
    {
        private bool IsShow { get; set; } = true;

        private void OnGUI()
        {
            if (AppConst.Environment == Environment.Production &&
                Application.platform != RuntimePlatform.WindowsEditor &&
                Application.platform != RuntimePlatform.OSXEditor)
                return;
            GUI.skin.button.fontSize = Screen.width / 30;
            GUI.skin.label.fontSize = Screen.width / 30;
            if (GUI.Button(new Rect(500, 50, 400, 100), "Show/Hide"))
            {
                IsShow = !IsShow;
            }

            if (!IsShow) return;
            GUI.Label(new Rect(50, 0, 500, 80), $"TimeScale={Time.timeScale}");
            GUI.Label(new Rect(50, 100, 500, 80), $"{SystemInfo.graphicsDeviceType}");
            if (GUI.Button(new Rect(50, 200, 400, 100),
                $"插屏状态：{(ConfigMgr.Ins.ConfigModel.showInter == 0 ? "关" : "开")}"))
            {
                ConfigMgr.Ins.ConfigModel.showInter = ConfigMgr.Ins.ConfigModel.showInter == 0 ? 1 : 0;
            }

            if (GUI.Button(new Rect(50, 350, 400, 100),
                $"激励状态：{(ConfigMgr.Ins.ConfigModel.showReward == 0 ? "关" : "开")}"))
            {
                ConfigMgr.Ins.ConfigModel.showReward = ConfigMgr.Ins.ConfigModel.showReward == 0 ? 1 : 0;
            }
        }

        public void Update()
        {
            if (Input.GetKeyDown(KeyCode.A))
            {
                Time.timeScale *= 2;
                Debug.Log($"当前TimeScale:{Time.timeScale}");
            }

            if (Input.GetKeyDown(KeyCode.D))
            {
                Time.timeScale /= 2;
                Debug.Log($"当前TimeScale:{Time.timeScale}");
            }

            if (Input.GetKeyDown(KeyCode.F))
            {
                Debug.Log("123456");
            }
        }
    }
}